package com.project.controller;

import com.project.util.UserBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
@RequestMapping("test")
public class TestController {
    @RequestMapping("showInfo")
    public String showInfo(HttpServletRequest request){
        //在请求对象中绑定数据
        request.setAttribute("name","张翠山");
        request.setAttribute("imgPath","1.jpg");
        request.setAttribute("userId",6);
        request.setAttribute("grade",50);
        request.setAttribute("pages",5);

        List<UserBean> userBeanList = List.of(
          new UserBean(1,"张思","男"),new UserBean(2,"刘五","男"),
                new UserBean(4,"张无极","男"),new UserBean(5,"六大思","男")
        );
        request.setAttribute("userList",userBeanList);

        return "/html/index.html";
    }

    @RequestMapping("del")
    public void del(int id){
        System.out.println(id);
    }
}
